<template>
	<view>
		<view class="list" @click="tojianli">
			<image src="@/static/jianlis.png" alt="" style="width: 50upx;height: 50upx;"></image>
			<view style="display: flex;flex-direction: column;padding-left: 20upx;">
				<text>个人在线简历</text>
			</view>
		</view>
		<view class="list" v-if="userinfo.resume_url!==''">
			<img :src="userinfo.resume_url" alt="" style="width: 50upx;height: 70upx;" @click="previewImg">
			<view style="display: flex;flex-direction: column;padding-left: 20upx;">
				<text>个人资料简历</text>
			</view>
		</view>


		<uni-file-picker v-model="value" fileMediatype="image"  :limit="1" @progress="progress" @success="success"
			@fail="fail" @select="select" style="margin-top: 50upx;">
			<view style="width: 690upx;height: 80upx;background: #EEEEEE;border-radius: 10upx;text-align: center;line-height: 80upx;">
				上传文件
			</view>
		</uni-file-picker>

	</view>
</template>

<script>
	import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
	import {
		pathToBase64,
		base64ToPath
	} from '@/components/mmmm-image-tools/index.js'
	export default {
		data() {
			return {
				// 上传接口参数
				option: {
					// 上传服务器地址，此地址需要替换为你的接口地址
					url: 'https://dsx.cdzer.com/api/MemberInfo/uploadfile',
					// 上传附件的key
					name: 'file',
					// 根据你接口需求自定义请求头
					header: {
						// 'Authorization': 'bearer eyJhbGciOiJSUzI1NiIsI',
						// 'uid': '27682',
						// 'client': 'app',
						// 'accountid': 'DP',
					},
					// 根据你接口需求自定义body参数
					formData: {
						// 'orderId': 1000
					}
				},
				// 选择文件后是否立即自动上传，true=选择后立即上传
				instantly: false,
				// 必传宽高且宽高应与slot宽高保持一致
				width: '180rpx',
				height: '180rpx',
				// 限制允许选择的格式，空串=不限制，默认为空
				formats: 'png,jpg,mp4,pdf,doc,docx,ppt',
				// 文件上传大小限制
				size: 10,
				// 文件回显列表
				files: new Map(),
				// 微信小程序Map对象for循环不显示，所以转成普通数组，不要问为什么，我也不知道
				wxFiles: [],
				// 是否打印日志
				debug: true,

				// 演示用
				tabIndex: 0,
				list: [],
				text: '',
				imageValue: [],
				fenleilist: ["呵呵哒", "么么哒"],
				options: [],
				value: [],
				turl: '',
				shopId: '',
				titles: '',
				imageValue: [],
				ishuati: '',
				dianzan: '',
				ceshiData: [],
				ht: [],
				max: 50,
				nums: 1,
				imglist: [],
				chooseImg: [],
				goodsid: '',
				src: '',
				jindu: 0,
				isShow: false,
				dataList: [],
				types: 'video',
				turl: '',
				tvideo: '',
				goodsinfo: {},
				describe: '',
				imgurl: '',
				spurl: '',
				cate_id: null,
				huatilist: [],
				userInfo: {},
				huatiId: [],
				type_id: null,
				useid:'',
				userinfo:{},
			}
		},
		components: {
			htzImageUpload,
		},
		onLoad(option) {
			this.useid = option.useid
			this.getinfo()
			
		},
		methods: {
			tojianli(){
				uni.navigateTo({
					url:`./fujian?useid=${this.useid}`
				})
			},
			getinfo(){
				uni.request({
					url: 'https://dsx.cdzer.com/api/MemberInfo/getuserinfo', //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						uid: this.useid
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded',
					},
					success: (res) => {
						console.log(res, "sdadasdasdas")
						this.userinfo = res.data.data
					}
				});
			},
			previewImg(logourl) {
				let _this = this;
				let imgsArray = [];
				imgsArray[0] = _this.userinfo.resume_url
				uni.previewImage({
					current: 0,
					urls: imgsArray
				});
			},
			// 获取上传状态
			select(e) {
				console.log('选择文件：', e)
				pathToBase64(e.tempFilePaths[0]).then(base64 => {
					// this.turl = base64
					// console.log(this.turl,"this.turlthis.turl")
					uni.request({
						url: 'https://dsx.cdzer.com/api/MemberInfo/uploadImage', //仅为示例，并非真实接口地址。
						data: {
							cover_image: base64,
							uid:1333
						},
						header: {
							'content-type': 'application/x-www-form-urlencoded',
						},
						method: 'POST',
						success: (res) => {
							console.log(res, "上传视频封面")
							this.getinfo()
							// this.imgurl = res.data.data.image_path
						}
					});
				}).catch(error => {
					console.log(error)
				})
			},
			// 获取上传进度
			progress(e) {
				console.log('上传进度：', e)
			},

			// 上传成功
			success(e) {
				console.log('上传成功')
				let uploadFileTask = plus.uploader.createUpload(
					"https://dsx.cdzer.com/api/MemberInfo/uploadfile", {
						method: "POST",
						headers: {
							// 修改请求头Content-Type类型 此类型为文件上传
							"Content-Type": "application/x-www-form-urlencoded"
						}
					},
					// data：服务器返回的响应值 status: 网络请求状态码
					(data, status) => {
						// 请求上传文件成功
						if (status == 200) {
							console.log(data, "sadsadasd")
							// 获取data.responseText之后根据自己的业务逻辑做处理
							let result = data.responseText;
				
						}
						// 请求上传文件失败
						else {
							console.log("上传失败", status)
						}
					}
				);
				uploadFileTask.addFile(e.tempFilePaths[0], {
					key: "file_data" // 填入图片文件对应的字段名
				});
				
				uploadFileTask.addData("uid", 1313);
				
				uploadFileTask.start();
			},

			// 上传失败
			fail(e) {
				console.log('上传失败：', e)
				
			},
		}
	}
</script>

<style scoped lang="scss">
	.list {
		padding: 30upx;
		display: flex;
		align-items: center;
		border-bottom: 2upx solid #EEEEEE;
	}
</style>
